#ifndef MYECPOINT_H
#define MYECPOINT_H
#include<openssl/ec.h>
#include<openssl/obj_mac.h>
#include"MyBIGNUM.h"
#include "qtypes.h"
#include<memory>
#include<iostream>
class MyECPoint
{
public:
    MyECPoint(EC_GROUP* group);
    MyECPoint(std::shared_ptr<EC_GROUP> mpGroup);
    MyECPoint(int group_nid);
    MyECPoint(const MyECPoint& other);
    MyECPoint(MyECPoint&& other);
    bool setPoint(EC_POINT* point,bool copy=true);
    bool setPoint(MyBIGNUM x, MyBIGNUM y);
    bool setPointFromOct(uchar* buf,int len);
    bool setPointFromRand();
    bool setPointFromHex(std::string hex);
    bool setPointFromHex(char* hex,int len);
    MyECPoint& operator=(const MyECPoint& other);
    ~MyECPoint();
    //加法
    MyECPoint operator+(const MyECPoint&);
    //减法
    friend MyECPoint operator-(const MyECPoint&);//取逆运算
    MyECPoint operator-(const MyECPoint&);       //减法
    //数乘运算
    MyECPoint operator*(const MyBIGNUM &);
    friend MyECPoint operator*(const MyBIGNUM &a,const MyECPoint& point);
    //打印
    friend std::ostream& operator<<(std::ostream& os, const MyECPoint& dt);
    //获取群信息
    bool getCurve(const MyBIGNUM& p,const MyBIGNUM& a,const MyBIGNUM& b);
    //to bin
    unsigned char* toOct(size_t& len);
    std::shared_ptr<unsigned char> toBuf(size_t& len);
    std::string toBuf();
private:
    std::shared_ptr<EC_GROUP> m_group;
    EC_POINT* m_point;
private:
    MyECPoint(EC_POINT* point, std::shared_ptr<EC_GROUP> group);
};

#endif // MYECPOINT_H
